import 'package:flutter/widgets.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';

class LoadingUtil {
  static void configLoading() {
    EasyLoading.instance
      ..radius = 20.0
      ..loadingStyle = EasyLoadingStyle.light
      ..maskType = EasyLoadingMaskType.black // 遮罩
      ..userInteractions = true;
  }

  static void showToast(String msg) {
    EasyLoading.showToast(msg);
    //  延时2秒
    Future.delayed(const Duration(seconds: 2), () {
      EasyLoading.dismiss();
    });
  }

  static Future<void> show({
    String? status,
    Widget? indicator,
    EasyLoadingMaskType? maskType,
    bool? dismissOnTap,
  }) {
    return EasyLoading.show(status: status, indicator: indicator, maskType: maskType, dismissOnTap: dismissOnTap);
  }

  static Future<void> dismiss({
    bool animation = true,
  }) {
    return EasyLoading.dismiss(animation: animation);
  }
}
